|
1
|
|
|
var WorkEnvironmentAPI = {}; |
|
2
|
|
|
WorkEnvironmentAPI.baseURL = "/tc/api/v1"; |
|
3
|
|
|
|
|
4
|
|
|
WorkEnvironmentAPI.photoNameToImgElementId = {'workplace_photo_1' : 'jobPosterWorkEnvironment_1', |
|
5
|
|
|
'workplace_photo_2' : 'jobPosterWorkEnvironment_2', |
|
6
|
|
|
'workplace_photo_3' : 'jobPosterWorkEnvironment_3'}; |
|
7
|
|
|
|
|
8
|
|
|
WorkEnvironmentAPI.defaultWorkplacePhoto = '/images/default_workplace_photo.png'; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* |
|
12
|
|
|
* @param {string} photo_name |
|
13
|
|
|
* @param {string} description |
|
14
|
|
|
* @return {WorkEnvironment.WorkplacePhotoCaption} |
|
15
|
|
|
*/ |
|
16
|
|
|
WorkEnvironmentAPI.WorkplacePhotoCaption = function(photo_name, description) { |
|
17
|
|
|
this.photo_name = photo_name; |
|
18
|
|
|
this.description = description; |
|
19
|
|
|
}; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* |
|
23
|
|
|
* @param {string} remote_allowed |
|
24
|
|
|
* @param {string} telework_allowed |
|
25
|
|
|
* @param {string} flexible_allowed |
|
26
|
|
|
* @param {WorkEnvironment.WorkplacePhotoCaption[]} workplace_photo_captions |
|
27
|
|
|
* @return {WorkEnvironment.WorkEnvironment} |
|
28
|
|
|
*/ |
|
29
|
|
|
WorkEnvironmentAPI.WorkEnvironment = function(remote_allowed, telework_allowed, |
|
30
|
|
|
flexible_allowed, workplace_photo_captions) { |
|
31
|
|
|
this.remote_allowed = remote_allowed; |
|
32
|
|
|
this.telework_allowed = telework_allowed; |
|
33
|
|
|
this.flexible_allowed = flexible_allowed; |
|
34
|
|
|
this.workplace_photo_captions = workplace_photo_captions; |
|
35
|
|
|
}; |
|
36
|
|
|
|
|
37
|
|
|
WorkEnvironmentAPI.parseWorkEnvironmentResponse = function(response) { |
|
38
|
|
|
console.log(response); |
|
|
|
|
|
|
39
|
|
|
var json = JSON.parse(response); |
|
40
|
|
|
var workEnvironment = new WorkEnvironmentAPI.WorkEnvironment( |
|
41
|
|
|
json.basic_work_environment.remote_allowed, |
|
42
|
|
|
json.basic_work_environment.telework_allowed, |
|
43
|
|
|
json.basic_work_environment.flexible_allowed, |
|
44
|
|
|
[] |
|
45
|
|
|
); |
|
46
|
|
|
for (var i=0; i<json.workplace_photo_captions.length; i++) { |
|
47
|
|
|
var caption = json.workplace_photo_captions[i]; |
|
48
|
|
|
var workplacePhotoCaption = new WorkEnvironmentAPI.WorkplacePhotoCaption( |
|
49
|
|
|
caption.photo_name, |
|
50
|
|
|
caption.description |
|
51
|
|
|
); |
|
52
|
|
|
workEnvironment.workplace_photo_captions.push(workplacePhotoCaption); |
|
53
|
|
|
} |
|
54
|
|
|
return workEnvironment; |
|
55
|
|
|
}; |
|
56
|
|
|
|
|
57
|
|
|
WorkEnvironmentAPI.localizeWorkEnvironment = function() { |
|
58
|
|
|
if (siteContent) { |
|
|
|
|
|
|
59
|
|
|
document.getElementById('jobPosterWorkEnvironmentLabel').innerHTML = siteContent.workEnvironment; |
|
60
|
|
|
|
|
61
|
|
|
document.getElementById('jobPosterRemoteWork_label').innerHTML = siteContent.remoteLocationAllowed; |
|
62
|
|
|
document.getElementById('jobPosterTelework_label').innerHTML = siteContent.teleworkAllowed; |
|
63
|
|
|
document.getElementById('jobPosterFlexHours_label').innerHTML = siteContent.flexHoursAllowed; |
|
64
|
|
|
} |
|
65
|
|
|
}; |
|
66
|
|
|
|
|
67
|
|
|
WorkEnvironmentAPI.loadWorkEnvironmentBrowseJobs = function(managerProfileId, labelID) { |
|
68
|
|
|
|
|
69
|
|
|
DataAPI.getWorkplaceEnvironment(managerProfileId, function(response) { |
|
|
|
|
|
|
70
|
|
|
var workEnv = WorkEnvironmentAPI.parseWorkEnvironmentResponse(response); |
|
71
|
|
|
WorkEnvironmentAPI.populateWorkEnvironmentBrowseJobs(workEnv, labelID); |
|
72
|
|
|
}) |
|
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
} |
|
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
WorkEnvironmentAPI.populateWorkEnvironmentBrowseJobs = function(workEnvironment, labelID) { |
|
77
|
|
|
|
|
78
|
|
|
var jobCardRemote = document.getElementById(labelID); |
|
79
|
|
|
|
|
80
|
|
|
if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Yes'){ |
|
|
|
|
|
|
81
|
|
|
jobCardRemote.innerHTML = 'Allowed'; |
|
82
|
|
|
} |
|
83
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Oui') { |
|
84
|
|
|
jobCardRemote.innerHTML = 'Autorisé'; |
|
85
|
|
|
} |
|
86
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'No') { |
|
87
|
|
|
jobCardRemote.innerHTML = 'Not Allowed'; |
|
88
|
|
|
} |
|
89
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Non') { |
|
90
|
|
|
jobCardRemote.innerHTML = 'Non autorisé'; |
|
91
|
|
|
} |
|
92
|
|
|
else { |
|
93
|
|
|
jobCardRemote.innerHTML = 'Not Specified'; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
} |
|
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
WorkEnvironmentAPI.loadWorkEnvironmentSummary = function(managerProfileId) { |
|
99
|
|
|
//Fill text fields |
|
100
|
|
|
DataAPI.getWorkplaceEnvironment(managerProfileId, function(response) { |
|
|
|
|
|
|
101
|
|
|
var workEnv = WorkEnvironmentAPI.parseWorkEnvironmentResponse(response); |
|
102
|
|
|
WorkEnvironmentAPI.populateWorkEnvironmentSummary(workEnv); |
|
103
|
|
|
}) |
|
|
|
|
|
|
104
|
|
|
//Download photos |
|
105
|
|
|
for (photoName in WorkEnvironmentAPI.photoNameToImgElementId) { |
|
|
|
|
|
|
106
|
|
|
WorkEnvironmentAPI.refreshWorkplacePhoto(managerProfileId, photoName, WorkEnvironmentAPI.photoNameToImgElementId[photoName]); |
|
107
|
|
|
} |
|
108
|
|
|
}; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* |
|
112
|
|
|
* @param {WorkEnvironment.WorkEnvironment} workEnvironment |
|
113
|
|
|
* @return {undefined} |
|
114
|
|
|
*/ |
|
115
|
|
|
WorkEnvironmentAPI.populateWorkEnvironmentSummary = function(workEnvironment) { |
|
116
|
|
|
|
|
117
|
|
|
document.getElementById('jobPosterRemoteWork').innerHTML = SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed); |
|
|
|
|
|
|
118
|
|
|
document.getElementById('jobPosterTelework').innerHTML = SliderAPI.getFrequencySliderLabel(workEnvironment.telework_allowed); |
|
119
|
|
|
document.getElementById('jobPosterFlexHours').innerHTML = SliderAPI.getFrequencySliderLabel(workEnvironment.flexible_allowed); |
|
120
|
|
|
|
|
121
|
|
|
for(var i=0; i<workEnvironment.workplace_photo_captions.length; i++) { |
|
122
|
|
|
var caption = workEnvironment.workplace_photo_captions[i]; |
|
123
|
|
|
var imgId = WorkEnvironmentAPI.photoNameToImgElementId[caption.photo_name]; |
|
124
|
|
|
if (imgId) { |
|
125
|
|
|
document.getElementById(imgId).setAttribute('title', caption.description); |
|
126
|
|
|
} |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
// TAL-150 - Remote work values for heading section |
|
130
|
|
|
if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Yes'){ |
|
131
|
|
|
document.getElementById('jobPosterRemoteWorkHeader').innerHTML = 'Remote Work Allowed'; |
|
132
|
|
|
} |
|
133
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Oui') { |
|
134
|
|
|
document.getElementById('jobPosterRemoteWorkHeader').innerHTML = 'Travail à distance autorisé'; |
|
135
|
|
|
} |
|
136
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'No') { |
|
137
|
|
|
document.getElementById('jobPosterRemoteWorkHeader').innerHTML = 'Remote Work Not Allowed'; |
|
138
|
|
|
} |
|
139
|
|
|
else if (SliderAPI.getYesNoSliderLabel(workEnvironment.remote_allowed) === 'Non') { |
|
140
|
|
|
document.getElementById('jobPosterRemoteWorkHeader').innerHTML = 'Travail à distance non autorisé'; |
|
141
|
|
|
} |
|
142
|
|
|
else { |
|
143
|
|
|
document.getElementById('jobPosterRemoteWorkHeader').innerHTML = 'Remote Work Not Specified'; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
}; |
|
147
|
|
|
|
|
148
|
|
|
WorkEnvironmentAPI.refreshWorkplacePhoto = function(managerProfileId, photoName, imageElementId) { |
|
149
|
|
|
var photoUrl = WorkEnvironmentAPI.baseURL+'/getWorkplacePhotoByManagerProfileAndName/'+ managerProfileId + '/' + photoName; |
|
150
|
|
|
var headers = {"Accept":"image/*"}; |
|
151
|
|
|
DataAPI.sendRequest(photoUrl, "GET", headers, null, function(request) { |
|
|
|
|
|
|
152
|
|
|
var img = document.getElementById(imageElementId); |
|
153
|
|
|
if (request.status == 200 && request.responseURL) { |
|
154
|
|
|
img.style.backgroundImage = "url("+request.responseURL+")"; |
|
155
|
|
|
} else { |
|
156
|
|
|
img.setAttribute('style','display:none;'); |
|
157
|
|
|
} |
|
158
|
|
|
}); |
|
159
|
|
|
}; |
|
160
|
|
|
|